package com.amit;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



@WebServlet(name="mylogin",urlPatterns={"/login.jlc"})
public class LoginServlet  extends HttpServlet{

public LoginServlet()
	{
		System.out.println("Default constructor");
	}

public LoginServlet(int ab)
	{
		System.out.println("parameterized constructor");
	}
	
	public static void main(String[] args) {
		
		System.out.println("Main()");
	}
	
	@Override
		public  void service(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
		
		//1.get tha data
		
		String uname=request.getParameter("username");
		

		String pwd=request.getParameter("password");
		
		//2.process the data
		String message=" ";
		
		if(uname.equals(pwd))
		{
			message="<h1><center>Login successful<br>" +"This is ur page</center></h1>";
		}
		else
		{
			message="<h1><center>Login not successful<br>" +"please try again</center></h1>";
		}
		
		
		//3.prepare response
		
		response.setContentType("text/html");
		Writer wr=response.getWriter();
		
		wr.write(message);
			
			//super.service(request, response);
		}

}
